PLOTY¶

In [1]:
import plotly.express as px
import pandas as pd
import numpy as np
In [4]:
fig=px.line(x=["india","australia","england"],y=[137,55,60])
fig.show()
In [5]:
import plotly.express as px
df=px.data.iris()
print(df.head())
   sepal_length  sepal_width  petal_length  petal_width species  species_id
0           5.1          3.5           1.4          0.2  setosa           1
1           4.9          3.0           1.4          0.2  setosa           1
2           4.7          3.2           1.3          0.2  setosa           1
3           4.6          3.1           1.5          0.2  setosa           1
4           5.0          3.6           1.4          0.2  setosa           1
In [7]:
df=px.data.iris()
fig=px.line(df,x="species",y="sepal_length")
fig.show()
In [8]:
fig=px.histogram(df,x="species",y="sepal_length")
fig.show()
In [9]:
fig=px.scatter(df,x="species",y="sepal_length")
fig.show()
In [10]:
fig=px.bar(df,x="species",y="sepal_length")
fig.show()
In [14]:
fig=px.line(df,x="sepal_width",y="sepal_length",color="species")
fig.show()
In [15]:
fig=px.bar(df,x="sepal_width",y="sepal_length",color="species")
fig.show()
In [19]:
fig=px.box(df,x="species",y="sepal_length",color="species")
fig.show()
In [24]:
fig=px.violin(df,x="species",y="sepal_length",color="species")
fig.show()
In [28]:
fig=px.scatter_3d(df,x="species",y="sepal_length",z="sepal_width",color="species")
fig.show()
In [29]:
df=px.data.tips()
print(df)
     total_bill   tip     sex smoker   day    time  size
0         16.99  1.01  Female     No   Sun  Dinner     2
1         10.34  1.66    Male     No   Sun  Dinner     3
2         21.01  3.50    Male     No   Sun  Dinner     3
3         23.68  3.31    Male     No   Sun  Dinner     2
4         24.59  3.61  Female     No   Sun  Dinner     4
..          ...   ...     ...    ...   ...     ...   ...
239       29.03  5.92    Male     No   Sat  Dinner     3
240       27.18  2.00  Female    Yes   Sat  Dinner     2
241       22.67  2.00    Male    Yes   Sat  Dinner     2
242       17.82  1.75    Male     No   Sat  Dinner     2
243       18.78  3.00  Female     No  Thur  Dinner     2

[244 rows x 7 columns]
In [36]:
import plotly.graph_objects as go
xd=np.random.randint(1,20,30)
yd=np.random.randint(1,20,30)
fig=go.Figure(go.Scatter(x=xd,y=yd,mode="markers"))
fig.show()
In [41]:
fig=go.Figure(go.Scatter(x=xd,y=yd,mode="markers",fillcolor="red"))
fig.show()
In [47]:
fig=go.Figure(go.Pie(labels=xd,values=yd ))
fig.show()
In [48]:
fig=px.line(x=["potato","tomato","capsium","onion","garlic","chilly"],y=[180,155,170,190,167,177])
fig.show()
In [49]:
fig=px.bar(x=["potato","tomato","capsium","onion","garlic","chilly"],y=[180,155,170,190,167,177])
fig.show()
In [52]:
fig=px.scatter(x=["potato","tomato","capsium","onion","garlic","chilly"],y=[180,155,170,190,167,177])
fig.show()
In [60]:
fig=go.Figure(go.Pie(labels=["potato","tomato","capsium","onion","garlic","chilly"],values=[18,155,250,190,100,177],title="SuperMarket"))
fig.show()
In [ ]: